<?php
namespace Home\Controller;

class InfoController extends AdminController{

    private $_user;//用户表
    private $_userInfo ;//用户信息
    private $_district;//地区
	public function __construct(){
		parent::__construct();
		$this->_user=M('user');
		$this->_userInfo=M('userinfo');
		$this->_district=M('district');
	}
	public function index(){
		$id=$_SESSION['love_user']['id'];
		$iid = $id;
		$nid = $id;
		$data1 = $this->_user->find($nid);
		$data2 = $this->_userInfo->find($iid);
		dump($_SESSION);
		var_dump($data1);
		var_dump($data2);
		$this->assign('data1',$data1);
		$this->assign('data2',$data2);
		$this->display();
	}
	//执行修改
	public function update(){
		$uid = $_SESSION['love_user']['id'];
		$iid = $_SESSION['love_user']['id'];
		$this->_user->create() ;   //创建数据 获取post数据；
		$this->_userInfo->create() ;   //创建数据 获取post数据；
		$this->_user->where("id={$uid}")->save();
			if($this->_userInfo->where("uid={$iid}")->save()>0){
				$this->success('恭喜您，修改成功', U('Usercenter/index'));
			}else{
				$this->error('修改失败！');
			}
	}
	//处理json数据
	public function deal(){
		$id =I('get.id/d',0);
	/*	var_dump($id);*/
		$district = $this->_district->where("upid=$id")->select();
		// dump($district);
		// $dthis->assign('dis',$district);
		$this->ajaxReturn($district);
	}

}
